package com.yuanhua.sim.config;

import com.yuanhua.core.utils.SpringUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "netty")
@Data
public class Myconfig {
    private int simServerPort;
    private Boolean zkSwitch;
    private String zkRoot;
    private Long heartBeatTime;

    @Bean
    public AppConfiguration appConfiguration(){
       return new AppConfiguration(simServerPort, zkSwitch, zkRoot, heartBeatTime);
    }

    @Bean
    public SpringUtils getSpringUtils(ApplicationContext applicationContext) {
        SpringUtils.setApplicationContext(applicationContext);
        return new SpringUtils();
    }

}
